<?php
class ChamadaHomeController extends AppController {

	var $name = 'ChamadaHome';
	
    
    function beforeFilter(){
    	$this->Auth->allow("confirmacao",'enviaEmailConfirmacao','add');
    }

	
	/********************* ADMINISTRADOR ************************************/
	
	function admin_index() {
		$this->layout = 'admin';
		$this->loadModel('Noticia');
		$this->layout = 'admin';
		$chamada = $this->ChamadaHome->find('first');
		$this->set('chamada', $chamada);
		$this->set('noticia', $this->Noticia->find('first', array('conditions'=>array('id_noticias'=>$chamada['ChamadaHome']['noticias_id']))));
	}
	
	function admin_add($id = null){
		$this->layout = 'admin';
		$this->loadModel('Noticia');
		if (!empty($this->data)) {
			if ($this->ChamadaHome->save($this->data)) {
				$this->Session->setFlash(__('Salvo com sucesso', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('Não pôde ser salva. Por favor, tente novamente.', true));
			}
		}
		$this->set('noticias', $this->Noticia->find('list', array('order'=>'date_data DESC')));
	if (empty($this->data)) {
			$this->data = $this->ChamadaHome->read(null, $id);
		}
	}	
}
?>